from registry.v2 import v2
import registry.readConfig as readConfig
import registry.forward as fw


def getV2(auth: fw.Auth) -> v2:
    """
    获取v2对象
    """
    forward = fw.Forward(auth)
    return v2(forward)


def getAuth(host: str, user: str = None, passwd: str = None, https: bool = False) -> fw.Auth:
    """
    获取认证对象
    """
    return fw.Auth(host, user, passwd, https)

def getConfigV2() -> v2:
    """
    读取配置文件
    """
    auth = readConfig.getConfigAuth()
    if auth is None:
        return None
    return getV2(auth)
